Fix routing YAML best results export#1422
Conversation
📝 WalkthroughWalkthroughThe PR updates best result YAML serialization to preserve an interval of zero and adds temporary-file test coverage that parses and verifies the resulting configuration. ChangesBest results serialization and validation
Estimated code review effort: 2 (Simple) | ~8 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@python/cuopt/cuopt/tests/routing/test_solver_settings.py`:
- Around line 56-58: Tests use hardcoded filenames (config_file =
"solver_cfg.yaml", best_results_file = "best_results.txt") when calling
s.dump_config_file and s.dump_best_results which can collide in parallel runs;
change to use the pytest tmp_path fixture to create per-test files/paths (e.g.,
tmp_path / "solver_cfg.yaml" and tmp_path / "best_results.txt") and pass those
Path strings to s.dump_config_file and s.dump_best_results, and apply the same
tmp_path-based replacements for the other occurrences referenced around lines
72-75 so each test writes to isolated temporary files.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: aad36dbe-fcf2-4f80-ba50-bb871cf12d09
📒 Files selected for processing (2)
python/cuopt/cuopt/routing/utils.pypython/cuopt/cuopt/tests/routing/test_solver_settings.py
|
🔔 Hi @anandhkb, this pull request has had no activity for 7 days. Please update or let us know if it can be closed. Thank you! If this is an "epic" issue, then please add the "epic" label to this issue. |
4 similar comments
|
🔔 Hi @anandhkb, this pull request has had no activity for 7 days. Please update or let us know if it can be closed. Thank you! If this is an "epic" issue, then please add the "epic" label to this issue. |
|
🔔 Hi @anandhkb, this pull request has had no activity for 7 days. Please update or let us know if it can be closed. Thank you! If this is an "epic" issue, then please add the "epic" label to this issue. |
|
🔔 Hi @anandhkb, this pull request has had no activity for 7 days. Please update or let us know if it can be closed. Thank you! If this is an "epic" issue, then please add the "epic" label to this issue. |
|
🔔 Hi @anandhkb, this pull request has had no activity for 7 days. Please update or let us know if it can be closed. Thank you! If this is an "epic" issue, then please add the "epic" label to this issue. |
Signed-off-by: Minh Vu <vuhoangminh97@gmail.com>
Summary
Routing YAML export used
dict.updatewith a set when best-results settings were enabled. That raises at runtime instead of writingbest_result_pathandbest_result_interval.This writes those fields with normal key assignment and treats
Noneas the only missing interval value, so an explicit interval of0is preserved.Reproduction
Running the original serialization logic gives:
With this change, both intervals serialize the configured path and interval.
Validation
python3 -m py_compile python/cuopt/cuopt/routing/utils.py python/cuopt/cuopt/tests/routing/test_solver_settings.pypre-commit run --files python/cuopt/cuopt/routing/utils.py python/cuopt/cuopt/tests/routing/test_solver_settings.py --show-diff-on-failuregit diff --checkNot run locally:
PYTHONPATH=python/cuopt uvx --with 'pytest<9.0' --with pyyaml --with numpy pytest python/cuopt/cuopt/tests/routing/test_solver_settings.py -k 'dump_config' -qcould not collect becausecudfis not installed in this local environment.